cmake_minimum_required (VERSION 3.8)
project(xdemo C CXX)

set(CMAKE_CXX_STANDARD 11)
find_package(CURL CONFIG REQUIRED)
include_directories(
   ../common/base
   ../common/uart
   ../common/net
   ../common/view
   ./src/project
   ./src/window
   ./src/protocol
   ${CDROID_INCLUDE_DIRS}
   ${CDROID_DEPINCLUDES}
   ${CMAKE_BINARY_DIR}/include
   ${CMAKE_BINARY_DIR}/include/gui
   ${CMAKE_BINARY_DIR}/include/porting
   ${CMAKE_BINARY_DIR}/include/cairo
   ${CMAKE_BINARY_DIR}/include/epg
   ${CMAKE_BINARY_DIR}/include/freetype2
   ${CURL_LIBRARIES}
)
aux_source_directory(./ XDEMO_SRCS)
aux_source_directory(./src/project XDEMO_SRC_PROJECT)
aux_source_directory(./src/window XDEMO_SRCS_WINDOW)
aux_source_directory(./src/protocol XDEMO_SRCS_PROTOCOL)

add_definitions(--include cdtypes.h)
add_definitions(--include cdlog.h)

link_directories(${CMAKE_BINARY_DIR}/lib ../common)

add_executable(xdemo ${XDEMO_SRCS} ${XDEMO_SRC_PROJECT}
  ${XDEMO_SRCS_WINDOW} ${XDEMO_SRCS_PROTOCOL})

CreatePAK(xdemo ${PROJECT_SOURCE_DIR}/assets ${PROJECT_BINARY_DIR}/xdemo.pak ${PROJECT_SOURCE_DIR}/R.h)

add_custom_target(xdemo_version
	COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/sh_ver.sh
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  COMMENT "create_version info")
add_dependencies(xdemo xdemo_version)

message("CDROID_LIBRARIES=${CDROID_LIBRARIES} CDROID_INCLUDE_DIRS=${CDROID_INCLUDE_DIRS}")
target_link_libraries(xdemo PRIVATE app_common cdroid CURL::libcurl)

install(TARGETS xdemo DESTINATION bin)

